
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test_project/event_bus_utils/EventBus.dart';
import 'package:flutter_test_project/module/bus_test_page/components/bus_config.dart';

class BusTestSubWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        FlatButton(
          padding: EdgeInsets.symmetric(horizontal: 15),
          child: Container(
            height: 40,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(20)),
                gradient: LinearGradient(
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                    colors: [
                      Colors.blue,
                      Colors.amber,
                    ]
                )
            ),
            child: Center(
              child: Text(
                "login",
                style: TextStyle(
                    color: Colors.white,
                    fontSize: 15,
                    fontWeight: FontWeight.w600
                ),
              ),
            ),
          ),
          onPressed: (){
            print("login");
            bus.emit("login_state",LoginState.login);
          },
        ),
        FlatButton(
          child: Container(
            height: 40,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(20)),
                gradient: LinearGradient(
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                    colors: [
                      Colors.blue,
                      Colors.amber,
                    ]
                )
            ),
            child: Center(
              child: Text(
                "logout",
                style: TextStyle(
                    color: Colors.white,
                    fontSize: 15,
                    fontWeight: FontWeight.w600
                ),
              ),
            ),
          ),
          onPressed: (){
            print("logout");
            bus.emit("login_state",LoginState.logout);
          },
        ),
      ],
    );
  }

}